<%--
  Created by IntelliJ IDEA.
  User: 15540
  Date: 2021/11/1
  Time: 20:22
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>

    <style>
        * {
            border: none;

            margin: 0;
            padding: 0;
        }
        body {

        }
        .center {
            background-color: #fff;
            height: 600px;
            width: 600px;
            margin: 0 auto;
        }
        h1 {
            color: #495678;
            font-size: 35px;
            margin-top: 50px;

            text-align: center;

        }
        form {
            background-color: #495678;
            box-shadow: 4px 4px #3d4a65;
            border-radius: 20px;
            margin: 40px auto;
            padding: 40px 0 30px 40px;
            width: 280px;

        }
        .btn {
            color :#fff;
            outline: none;
            cursor: pointer;
            font-size: 20px;
            height: 45px;
            margin: 5px 0 5px 10px;
            width: 45px;
        }
        #display {
            box-shadow: rgb(241, 57, 36) 6px 6px  inset;

            text-indent: 5px;
            outline: none;
            width: 160px;
            height: 35px;
            font-size: 18px;
            border-radius: 5px;
            color: #fff;
            background-color: rgb(245, 139, 127);

        }

        .number {
            box-shadow: 0 2px #bebebe;
            border-radius: 22.5px;
            background-color: rgb(115, 119, 139) ;
        }
        .number:active {
            box-shadow: none;

            transform: translateY(2px);

        }
        .other {
            box-shadow: 0 2px #bebebe;
            border-radius: 22.5px;
            background-color: thistle;
        }
        .other:active {
            box-shadow: none;

            transform: translateY(2px);

        }
        .operator {
            box-shadow: 0 2px #bebebe;
            color: #000;
            border-radius: 22.5px;
            background-color: rgb(222, 222, 220) ;

        }
        .operator:active {
            box-shadow: none;

            transform: translateY(2px);
        }
    </style>
</head>
<body>
<div class="center">
    <h1> 计算器</h1>

    <form name="calculator">
        <input type="button" id="clear" class="btn other" value="C" onclick="clear1()">
        <input type="text" id="display" >
        <br>
        <input type="button" class="btn number" value="7" onclick="get(this.value);">
        <input type="button" class="btn number" value="8" onclick="get(this.value);">
        <input type="button" class="btn number" value="9" onclick="get(this.value);">
        <input type="button" class="btn operator" value="+" onclick="get(this.value);">
        <br>
        <input type="button" class="btn number" value="4" onclick="get(this.value);">
        <input type="button" class="btn number" value="5" onclick="get(this.value);">
        <input type="button" class="btn number" value="6" onclick="get(this.value);">
        <input type="button" class="btn operator" value="*" onclick="get(this.value);">
        <br>
        <input type="button" class="btn number" value="1" onclick="get(this.value);">
        <input type="button" class="btn number" value="2" onclick="get(this.value);">
        <input type="button" class="btn number" value="3" onclick="get(this.value);">
        <input type="button" class="btn operator" value="-" onclick="get(this.value);">
        <br>
        <input type="button" class="btn number" value="0" onclick="get(this.value);">
        <input type="button" class="btn operator" value="." onclick="get(this.value);">
        <input type="button" class="btn operator" value="/" onclick="get(this.value);">
        <input type="button" class="btn other" value="=" onclick="calculates();">

    </form>
    <script>
        function clear1() {
            document.getElementById("display").value = "";
        };

        function get(value) {
            document.getElementById("display").value += value;
        }

        function calculates() {
            var result = 0;
            result = document.getElementById("display").value;

            document.getElementById("display").value=eval(result);
        };
    </script>
</div>
</body>
</html>
